home *** CD-ROM | disk | FTP | other *** search
/ Shareware Super Platinum 8 / Shareware Super Platinum 8.iso / mac / PROGTOOL / FLI106C.ZIP;1 / WINTILE.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1992-03-12  |  2.5 KB  |  106 lines

  1. //
  2. // The Fusion Library Interface for DOS
  3. // Version 1.06c
  4. // Copyright (C) 1990, 1991, 1992
  5. // Software Dimensions
  6. //
  7. // FusionWindow
  8. //
  9.  
  10. #include "fliwin.h"
  11.  
  12. #ifdef __BCPLUSPLUS__
  13. #pragma hdrstop
  14. #endif
  15.  
  16. //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  17. //
  18. // TileWindows()
  19. //
  20. // Tiles the windows
  21. //
  22. //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  23.  
  24. void FusionWindow::TileWindows()
  25. {
  26.   if (NumberOfWindows<2)
  27.     return;
  28.  
  29.   int Calculation;
  30.   int NumberOfWindows=FusionWindow::NumberOfWindows;
  31.   int OddFlag=0;
  32.  
  33.   if (NumberOfWindows&1)
  34.   {
  35.     OddFlag=1;
  36.     NumberOfWindows++;
  37.   }
  38.  
  39.   Calculation=NumberOfWindows/2;
  40.  
  41.   if ((BlazeClass::WhatWidth()/Calculation)<13)
  42.   {
  43.     do { } while ((BlazeClass::WhatWidth()/(--Calculation))<13);
  44.   }
  45.  
  46.   int WindowsOnScreen=Calculation*2;
  47.   int SplitWindows=Calculation;
  48.   int CurrentWindow=NumberOfWindows-1-((OddFlag)?1:0);
  49.   int TopHeight=(BlazeClass::WhatHeight()-2)/2;
  50.   int BottomHeight=(BlazeClass::WhatHeight()-2)-TopHeight;
  51.   int BottomY=TopHeight+1;
  52.  
  53.   do
  54.   {
  55.     for (int i=0;i<WindowsOnScreen;i++)
  56.     {
  57.       if (CurrentWindow==-1)
  58.         break;
  59.  
  60.       int X, Y, Width, Height, WidthAdjust=1;
  61.  
  62.       if (!CurrentWindow && i<WindowsOnScreen-1)
  63.       {
  64.         if (i<SplitWindows)
  65.           WidthAdjust=(SplitWindows-i)+1;
  66.         else
  67.           WidthAdjust=(WindowsOnScreen-i)+1;
  68.       }
  69.  
  70.       if (i<SplitWindows) // on top of screen
  71.       {
  72.         Y=1;
  73.         Height=TopHeight;
  74.         Width=((BlazeClass::WhatWidth())/SplitWindows)*WidthAdjust;
  75.         X=i*(Width/WidthAdjust);
  76.         if (X+Width>BlazeClass::WhatWidth())
  77.           Width=Width-((X+Width)-BlazeClass::WhatWidth());
  78.         else if (i==SplitWindows-1)
  79.           Width+=(BlazeClass::WhatWidth()-(X+Width));
  80.       }
  81.       else // on bottom of screen
  82.       {
  83.         Y=BottomY;
  84.         Height=BottomHeight;
  85.         Width=((BlazeClass::WhatWidth())/SplitWindows)*WidthAdjust;
  86.         X=((i-SplitWindows)*(Width/WidthAdjust));
  87.         if (X+Width>BlazeClass::WhatWidth())
  88.           Width=Width-((X+Width)-BlazeClass::WhatWidth());
  89.         else if (i==WindowsOnScreen-1)
  90.           Width+=(BlazeClass::WhatWidth()-(X+Width));
  91.       }
  92.  
  93.       Windows[CurrentWindow]->X=X;
  94.       Windows[CurrentWindow]->Y=Y;
  95.       Windows[CurrentWindow]->Width=Width;
  96.       Windows[CurrentWindow--]->Height=Height;
  97.     }
  98.   }
  99.   while (CurrentWindow>=0);
  100.  
  101.   RemoveAllMenus();
  102.   RefreshWindows();
  103. }
  104.  
  105.  
  106.